const mongoose = require('mongoose');

var orderInfoSchema = mongoose.Schema({
    merchant: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Merchant'
    },
    customer: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Customer'
    },
    foods: [{food:{
            type: mongoose.Schema.Types.ObjectId,
            ref: 'Food'
    },
            num: Number,
            subTotalMoney: Number // 子价钱
        }],
    address: String,
    phone: String,
    receiver: String,
    status: String,
    allTotalMoney: Number,  //总价钱
    createDate: Date  //订单日期
}, { collection: 'order_info' });

var OrderInfo = mongoose.model('OrderInfo', orderInfoSchema);

module.exports = OrderInfo;